import { defineStore } from 'pinia'
import { ref } from "vue";

// 组合式 
export const useUserStore = defineStore('user', () => {
    const profile = ref({})
    const setProfile = (userinfo) => {
        profile.value = userinfo
    }
    return {
        profile, setProfile
    }
}, {
    // 只在浏览器端下有效  小程序端无效
    // persist: true 

    // uniapp 重写存储数据的api
    persist: {
        // storage:localStorage,
        storage: {
            getItem(key) {
                return uni.getStorageSync(key)
            },
            setItem(key, val) {
                uni.setStorageSync(key, val)
            }
        }
    }

})
